package pl.elka.simulator.core.experiment;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import pl.elka.simulator.core.Constraint;
import pl.elka.simulator.core.EnviromentConfiguration;
import pl.elka.simulator.core.Node;

public class RaitingCounter {
	
	private EffectivnessRaitingCounter effectivnessCounter = new EffectivnessRaitingCounter();
	private ConsistencyRaitingCounter consistencyRaitingCounter = new ConsistencyRaitingCounter();
	
	public static String COMPLEXITY_RAITING = "complexity-raiting";
	public static String EFFECTIVENESS_RAITING = "effectiveness-raiting";
	public static String PERFORMANCE_RATTING = "performance-raiting";
	public static String USEFULNESS_RATTING = "usefuleness-raiting";
	public static String CONSISTENCY_RATTING = "consistency-raiting";
	
	public Map<String, Float> countRaitings(EnviromentConfiguration cfg,List<? extends Node> nodes,long epochs,long duration){
		Map<String,Float> raitings = new HashMap<String, Float>();
		long startTime = System.currentTimeMillis();
		float effectivnessRaiting = effectivnessCounter.countEffectiveness(cfg, nodes);
		float compexityRaiting = duration/((float)(nodes.size()*epochs*1000));
		float performanceRaiting = effectivnessRaiting/compexityRaiting;
		float useRaiting = effectivnessRaiting/nodes.size();			
		float consistencyRaiting = consistencyRaitingCounter.countConsistency(cfg,nodes,epochs);
		
		System.out.println("Obliczanie wskaznikow trwalo " + (System.currentTimeMillis()-startTime));
		
		raitings.put(EFFECTIVENESS_RAITING, effectivnessRaiting);
		raitings.put(COMPLEXITY_RAITING,compexityRaiting);		
		raitings.put(PERFORMANCE_RATTING,performanceRaiting);
		raitings.put(USEFULNESS_RATTING,useRaiting);
		raitings.put(CONSISTENCY_RATTING,consistencyRaiting);
		
		for(Map.Entry<String, Float> e:raitings.entrySet()){
			System.out.println(e.getKey()+"="+e.getValue());
		}
		
		return raitings;
	}
	
}
